import datetime
import pytz
import time

def time_to_datetime(stamp):
    # dt = datetime.datetime.strptime(string , '%Y-%m-%d %H:%M:%S')
    # ts = int(dt.timestamp())
    ts = int(stamp)
    t = datetime.datetime.fromtimestamp(ts, pytz.timezone('Asia/Shanghai'))
    return t

def now():
    return time_to_datetime(time.time())

if __name__ == "__main__":
    # string = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
    stamp = time.time()
    print(stamp)
    print(time_to_datetime(stamp), type(stamp))